package controlador;

import classes.CargoComissao;
import classes.CargoEfetivo;
import dao.CargoDao;
import erro.ConexaoException;
import erro.ConsultaException;
import java.util.ArrayList;
import javax.swing.JOptionPane;

/**
 *
 * @author Roberta
 */
public class CargoControlador {

    private CargoDao dao;
    CargoEfetivo ce = new CargoEfetivo();
    CargoComissao cc = new CargoComissao();

    public CargoControlador() {
        this.dao = new CargoDao();
    }
    /**
     * 
     * @param ce = CargoEfetivo
     * @throws ConexaoException
     * @throws ConsultaException 
     */
    public void inserir(CargoEfetivo ce) throws ConexaoException, ConsultaException {
        if (ce.getNome().trim().equals("")) {
            JOptionPane.showMessageDialog(null, "Digite o nome do Cargo.");
        } else {
            this.dao.inserir(ce);
        }
        if (ce.getCargoE_id() == 0) {
            ce.setCargoE_id(1);
        }
    }
    /**
     * 
     * @param cc = CargoComissao
     * @throws ConexaoException
     * @throws ConsultaException 
     */
    public void inserir(CargoComissao cc) throws ConexaoException, ConsultaException {
        if (cc.getNome().trim().equals("")) {
            JOptionPane.showMessageDialog(null, "Digite o nome do Cargo.");
        } else {
            this.dao.inserir(cc);
        }
        if (cc.getCargoC_id() == 0) {
            cc.setCargoC_id(1);
        }
    }
    /**
     * 
     * @param ce = CargoEfetivo
     * @return
     * @throws ConexaoException
     * @throws ConsultaException 
     */
    public ArrayList<CargoEfetivo> listarCE(CargoEfetivo ce) throws ConexaoException, ConsultaException {
        return (ArrayList<CargoEfetivo>) this.dao.listarCE();
    }
    /**
     * 
     * @param cc = CargoComissao
     * @return
     * @throws ConexaoException
     * @throws ConsultaException 
     */
    public ArrayList<CargoComissao> listarCC(CargoComissao cc) throws ConexaoException, ConsultaException {
        return (ArrayList<CargoComissao>) this.dao.listarCC();
    }
    /**
     * 
     * @param ce = CargoEfetivo
     * @return
     * @throws ConexaoException
     * @throws ConsultaException 
     */
    public CargoEfetivo pesquisar(CargoEfetivo ce) throws ConexaoException, ConsultaException {
        return (CargoEfetivo) this.dao.pesquisarCe(ce);
    }
    /**
     * 
     * @param cc = CargoComissao
     * @return
     * @throws ConexaoException
     * @throws ConsultaException 
     */
    public CargoComissao pesquisar(CargoComissao cc) throws ConexaoException, ConsultaException {
        return (CargoComissao) this.dao.pesquisarCc(cc);
    }
    /**
     * 
     * @param cc = CargoComissao
     * @throws ConexaoException
     * @throws ConsultaException 
     */
    public void deletar(CargoComissao cc) throws ConexaoException, ConsultaException {
        this.dao.deletar(cc);
    }
    /**
     * 
     * @param ce = CargoEfetivo
     * @throws ConexaoException
     * @throws ConsultaException 
     */
    public void deletar(CargoEfetivo ce) throws ConexaoException, ConsultaException {
        this.dao.deletar(ce);
    }
    /**
     * 
     * @param ce = CargoEfetivo
     * @throws ConexaoException
     * @throws ConsultaException 
     */
    public void alterarCe(CargoEfetivo ce) throws ConexaoException, ConsultaException {
       this.dao.alterarCe(ce); 
    }
    /**
     * 
     * @param cc = CargoComissao
     * @throws ConexaoException
     * @throws ConsultaException 
     */
    public void alterarCc(CargoComissao cc) throws ConexaoException, ConsultaException {
       this.dao.alterarCc(cc); 
    }
}
